package com.vineetmanohar.nitrogen;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * The result of path generation
 * 
 * @author vineetmanohar
 */
public class PathGenerationResult {
	// private Map<String, List<Model>> generatedPaths = new TreeMap<String,
	// List<Model>>();

	private Map<String, GeneratedPath> generatedPaths = new TreeMap<String, GeneratedPath>();

	// private List<GeneratedPath> generatedPathList = new
	// ArrayList<GeneratedPath>();

	/**
	 * Add the resolved path to the result. The model that was used to resolve
	 * the path
	 * 
	 * @param generatedPath
	 * @param objectModel
	 */
	public void add(String inputPath, String generatedPath,
			ObjectModel objectModel) {
		if (!generatedPaths.containsKey(generatedPath)) {
			generatedPaths.put(generatedPath, new GeneratedPath(inputPath,
					generatedPath));
		}

		generatedPaths.get(generatedPath).addPathGenerationContext(objectModel);
	}

	public Set<String> getGeneratedPathValues() {
		return generatedPaths.keySet();
	}

	public List<GeneratedPath> getGeneratedPaths() {
		return new ArrayList<GeneratedPath>(generatedPaths.values());
	}

	public GeneratedPath getCodeGenerationContext(String generatedPath) {
		return generatedPaths.get(generatedPath);
	}
}